package com.gewu.pm.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gewu.pm.R;
import com.gewu.pm.app.AppAdapter;
import com.gewu.pm.bean.TestBean;

/**
 * 账期延期单列表适配器
 */
public class PaymentTermPostponeAdapter extends AppAdapter<TestBean> {

    public PaymentTermPostponeAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ItemViewHolder();
    }

    private final class ItemViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView mTerminalNameView;
        private final TextView mCreateTimeView;
        private final TextView mPaymentTermNoView;
        private final TextView mPostponeOrderNoView;
        private final TextView mTerminalCodeView;
        private final TextView mAccountPeriodView;
        private final TextView mBufferPeriodView;
        private final TextView mUnsettledPeriodView;
        private final TextView mPeriodAmountView;
        private final TextView mSettledAmountView;
        private final TextView mOriginalDueDateView;
        private final TextView mCurrentDueDateView;
        private final TextView mVehicleCodeView;
        private final TextView mDeliveryProviderView;
        private final TextView mSalespersonView;
        private final TextView mSalesAreaView;

        private ItemViewHolder() {
            super(R.layout.payment_term_postpone_item);
            mTerminalNameView = findViewById(R.id.tv_terminal_name);
            mCreateTimeView = findViewById(R.id.tv_create_time);
            mPaymentTermNoView = findViewById(R.id.tv_payment_term_no);
            mPostponeOrderNoView = findViewById(R.id.tv_postpone_order_no);
            mTerminalCodeView = findViewById(R.id.tv_terminal_code);
            mAccountPeriodView = findViewById(R.id.tv_account_period);
            mBufferPeriodView = findViewById(R.id.tv_buffer_period);
            mUnsettledPeriodView = findViewById(R.id.tv_unsettled_period);
            mPeriodAmountView = findViewById(R.id.tv_period_amount);
            mSettledAmountView = findViewById(R.id.tv_settled_amount);
            mOriginalDueDateView = findViewById(R.id.tv_original_due_date);
            mCurrentDueDateView = findViewById(R.id.tv_current_due_date);
            mVehicleCodeView = findViewById(R.id.tv_vehicle_code);
            mDeliveryProviderView = findViewById(R.id.tv_delivery_provider);
            mSalespersonView = findViewById(R.id.tv_salesperson);
            mSalesAreaView = findViewById(R.id.tv_sales_area);
        }

        @Override
        public void onBindView(int position) {
            TestBean item = getItem(position);
            // 使用 TestBean 的字段
            mTerminalNameView.setText(item.getName());
            mCreateTimeView.setText("创建时间：2025-09-14 15:00:41");
            mPaymentTermNoView.setText(item.getId());
            mPostponeOrderNoView.setText(item.getId());
            mTerminalCodeView.setText("75973782233");
            mAccountPeriodView.setText("10天");
            mBufferPeriodView.setText("3天");
            mUnsettledPeriodView.setText("2025-08-01~2025-08-10");
            mPeriodAmountView.setText("¥1900.28");
            mSettledAmountView.setText("¥1000.28");
            mOriginalDueDateView.setText("2025-08-13");
            mCurrentDueDateView.setText("2025-08-16");
            mVehicleCodeView.setText("A123334");
            mDeliveryProviderView.setText("杭州小配送1号车");
            mSalespersonView.setText("张三");
            mSalesAreaView.setText("杭州-滨江");
        }
    }
}

